using System;
using MbUnit.Framework;

namespace ZSafeProjectNameZ.Tests
{
    [TestFixture(Order = 1)]
    public class SqlDataProviderFixturePreTest
    {
        [Test]
        public void ShouldGetValidSourceFolderPath()
        {
            Assert.IsTrue(System.IO.Directory.Exists(DatabaseEnvironment.SourceDatabaseFolderPath));
        }

        [Test]
        public void ShouldNotHaveParentReferenceInSourceFolderPath()
        {
            Assert.DoesNotContain(DatabaseEnvironment.SourceDatabaseFolderPath, "..");
        }

        [Test]
        public void ShouldReadTestDatabaseSetupScript()
        {
            // Arrange
            string scriptPath = System.IO.Path.Combine(DatabaseEnvironment.SourceDatabaseFolderPath, DatabaseEnvironment.TestDatabaseSetupScript);
            // Act
            string scriptText = System.IO.File.ReadAllText(scriptPath);
            // Assert
            Assert.IsFalse(string.IsNullOrEmpty(scriptText));
        }

        [Test]
        public void ShouldReadModuleUnInstallScript()
        {
            // Arrange
            string scriptPath = System.IO.Path.Combine(DatabaseEnvironment.SourceDatabaseFolderPath, DatabaseEnvironment.ModuleUnInstallScript);
            // Act
            string scriptText = System.IO.File.ReadAllText(scriptPath);
            // Assert
            Assert.IsFalse(string.IsNullOrEmpty(scriptText));
        }

        [Test]
        public void ShouldReadModuleInstallScripts()
        {
            // Arrange
            string scriptPath;

            foreach (string fileName in DatabaseEnvironment.ModuleInstallScripts)
            {
                // Act
                scriptPath = System.IO.Path.Combine(DatabaseEnvironment.SourceDatabaseFolderPath, fileName);
                string scriptText = System.IO.File.ReadAllText(scriptPath);
                // Assert
                Assert.IsFalse(string.IsNullOrEmpty(scriptText));
            }
        }
    }
}
